package com.woniuxy.car.boss.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.car.boss.client.PowerBossClient;
import com.woniuxy.car.boss.param.power.BossAddPileParam;
import com.woniuxy.car.boss.param.power.BossAddStationParam;
import com.woniuxy.car.boss.param.power.BossUpdatePileParam;
import com.woniuxy.car.boss.param.power.BossUpdateStationParam;
import com.woniuxy.car.common.resultcode.Result;
import com.woniuxy.car.power.client.PowerManageClient;
import com.woniuxy.car.power.client.param.AddPileParam;
import com.woniuxy.car.power.client.param.AddStationParam;
import com.woniuxy.car.power.client.param.UpdatePileParam;
import com.woniuxy.car.power.client.param.UpdateStationParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class PowerBossApiImpl implements PowerBossClient {
    @Resource
    private PowerManageClient powerManageClient;

    @Override
    public Result addStation(BossAddStationParam addStationParam) {

        log.info("请求参数：{}",addStationParam);
        AddStationParam addStationParam1 = BeanUtil.copyProperties(addStationParam, AddStationParam.class);

        return powerManageClient.addStation(addStationParam1);
    }

    @Override
    public Result updateStation(BossUpdateStationParam updateStationParam) {
        log.info("请求参数：{}",updateStationParam);
        UpdateStationParam updateStationParam1 = BeanUtil.copyProperties(updateStationParam, UpdateStationParam.class);
        return powerManageClient.updateStation(updateStationParam1);
    }

    @Override
    public Result delStation(Integer stationId) {
        log.info("请求参数：{}",stationId);
        return powerManageClient.delStation(stationId);
    }

    @Override
    public Result openStation(Integer stationId) {
        log.info("请求参数：{}",stationId);
        return powerManageClient.openStation(stationId);
    }

    @Override
    public Result closeStation(Integer stationId) {
        log.info("请求参数：{}",stationId);
        return powerManageClient.closeStation(stationId);
    }

    @Override
    public Result addPile(BossAddPileParam addPileParam) {
        log.info("请求参数：{}",addPileParam);
        AddPileParam addPileParam1 = BeanUtil.copyProperties(addPileParam, AddPileParam.class);
        return powerManageClient.addPile(addPileParam1);
    }

    @Override
    public Result updatePile(BossUpdatePileParam updatePileParam) {
        log.info("请求参数：{}",updatePileParam);
        UpdatePileParam updatePileParam1 = BeanUtil.copyProperties(updatePileParam, UpdatePileParam.class);
        return powerManageClient.updatePile(updatePileParam1);
    }

    @Override
    public Result delPile(Integer pileId, Integer stationId) {
        log.info("请求参数：{}",pileId,stationId);

        return powerManageClient.delPile(pileId,stationId);
    }

    @Override
    public Result setPileAbnormal(Integer pileId) {
        log.info("请求参数：{}",pileId);
        return powerManageClient.setPileAbnormal(pileId);
    }

    @Override
    public Result setPileNormal(Integer pileId) {
        log.info("请求参数：{}",pileId);
        return powerManageClient.setPileNormal(pileId);
    }

    @Override
    public Result setPileUsing(Integer pileId) {
        log.info("请求参数：{}",pileId);
        return powerManageClient.setPileUsing(pileId);
    }
}
